home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
ATPrefs.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-26
|
7KB
|
261 lines
/* ******************************************************************* */
/* ** ** */
/* ** ATKeyboard Version 3.0 ** */
/* ** Copright (C) 1992 by Thomas Dreibholz ** */
/* ** All rights reserved ** */
/* ** ** */
/* ** AT Preferences ** */
/* ** ** */
/* ******************************************************************* */
#define COLOR_VIDEO (1<<4)
#define MONO_VIDEO (1<<3)
#define SERIAL_PORT (1<<0)
#define SEGMENT_A000 (1<<5)
#define SEGMENT_D000 (1<<6)
#define SEGMENT_E000 ((1<<5)|(1<<6))
#define SEGMENT_NONE 0
#define ATP_UNUSED ((1<<7)|(1<<2)|(1<<1))
#define ITEM_VIDEO 0
#define SUBITEM_MONO 0
#define SUBITEM_COLOR 1
#define ITEM_ADRESSE 1
#define SUBITEM_A000 0
#define SUBITEM_D000 1
#define SUBITEM_E000 2
#define SUBITEM_NONE 3
#define ITEM_SERIAL 2
#define ITEM_ATPLADEN 4
#define ITEM_ATPSICHERN 5
#define ITEM_ATPSETZEN 6
#define SUBITEM_SYSTEM 0
#define SUBITEM_SIDECAR 1
extern struct MenuItem Color_Item;
extern struct MenuItem Mono_Item;
extern struct MenuItem A000_Item;
extern struct MenuItem D000_Item;
extern struct MenuItem E000_Item;
extern struct MenuItem None_Item;
extern struct MenuItem SerialPort_Item;
extern struct Menu Menu1;
extern struct Window *WindowPtr;
UBYTE ColorVideo=0,
MonoVideo=0,
SerialPort=0,
Segment=SEGMENT_D000;
/* Einstellungen zeigen */
VOID ZeigeATP(byte,menue)
UBYTE byte;
BOOL menue;
{
if(byte & COLOR_VIDEO) ColorVideo=COLOR_VIDEO; else ColorVideo=0;
if(byte & MONO_VIDEO) MonoVideo=MONO_VIDEO; else MonoVideo=0;
if(byte & SERIAL_PORT) SerialPort=SERIAL_PORT; else SerialPort=0;
Segment=SEGMENT_NONE;
if(byte & SEGMENT_D000) Segment=SEGMENT_D000;
if(byte & SEGMENT_A000) Segment=SEGMENT_A000;
if((byte & SEGMENT_A000) && (byte & SEGMENT_D000)) Segment=SEGMENT_E000;
if(menue==TRUE) ClearMenuStrip(WindowPtr);
if(ColorVideo) Aktiv(&Color_Item); else Inaktiv(&Color_Item);
if(MonoVideo) Aktiv(&Mono_Item); else Inaktiv(&Mono_Item);
if(SerialPort) Aktiv(&SerialPort_Item); else Inaktiv(&SerialPort_Item);
if(Segment==SEGMENT_A000) { Inaktiv(&D000_Item); Inaktiv(&E000_Item); Aktiv(&A000_Item); Inaktiv(&None_Item); }
if(Segment==SEGMENT_D000) { Inaktiv(&A000_Item); Inaktiv(&E000_Item); Aktiv(&D000_Item); Inaktiv(&None_Item); }
if(Segment==SEGMENT_E000) { Inaktiv(&D000_Item); Inaktiv(&A000_Item); Aktiv(&E000_Item); Inaktiv(&None_Item); }
if(Segment==SEGMENT_NONE) { Inaktiv(&D000_Item); Inaktiv(&A000_Item); Inaktiv(&E000_Item); Aktiv(&None_Item); }
if(menue==TRUE) SetMenuStrip(WindowPtr,&Menu1);
}
/* Lese Einstellungen aus Dual Ported RAM */
VOID LiesATP()
{
UBYTE byte;
byte=GetJanusPrefs();
ZeigeATP(byte,FALSE);
}
/* Lade Einstellungen */
BOOL LadeATP(dir,req)
UBYTE *dir;
BOOL req;
{
UBYTE byte;
register struct FileHandle *fh;
fh=Open(dir,MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,&byte,1L);
Close(fh);
ZeigeATP(byte,req);
}
else
{
if(req==TRUE)
{
Requester("Die Datei \"2500prefs\" konnte","nicht geöffnet werden.","Okay",NULL);
}
return(FALSE);
}
return(TRUE);
}
/* Prefs sichern */
VOID SichereATP(dir,req)
UBYTE *dir;
BOOL req;
{
UBYTE byte;
register struct FileHandle *fh;
fh=Open(dir,MODE_NEWFILE);
if(fh!=NULL)
{
byte=ColorVideo+MonoVideo+SerialPort+Segment+ATP_UNUSED;
Write(fh,&byte,1L);
SetJanusPrefs(&byte);
Close(fh);
}
else
{
if(req==TRUE)
{
Requester("Die Datei \"2500prefs\" konnte","nicht geschrieben werden.","Okay",NULL);
}
}
}
#asm
* Prefs an Janus senden
public _SetJanusPrefs
public _GetJanusPrefs
public _JanusBase
_SetJanusPrefs:
move.l _JanusBase,a6
move.l 46(a6),a0
move.l 4(sp),a6
move.b (a6),8183(a0)
rts
_GetJanusPrefs:
move.l _JanusBase,a6
move.l 46(a6),a0
move.b 8183(a0),d0
ext.w d0
ext.l d0
rts
#endasm
/* AT-Preferences-Verwaltung */
VOID ATPrefs(item,sub)
WORD item,sub;
{
UBYTE byte,ok;
switch(item)
{
case ITEM_ADRESSE:
ClearMenuStrip(WindowPtr);
switch(sub)
{
case SUBITEM_A000:
Aktiv(&A000_Item);
Inaktiv(&D000_Item);
Inaktiv(&E000_Item);
Inaktiv(&None_Item);
Segment=SEGMENT_A000;
break;
case SUBITEM_D000:
Aktiv(&D000_Item);
Inaktiv(&A000_Item);
Inaktiv(&E000_Item);
Inaktiv(&None_Item);
Segment=SEGMENT_D000;
break;
case SUBITEM_E000:
Aktiv(&E000_Item);
Inaktiv(&D000_Item);
Inaktiv(&A000_Item);
Inaktiv(&None_Item);
Segment=SEGMENT_E000;
break;
case SUBITEM_NONE:
Inaktiv(&E000_Item);
Inaktiv(&D000_Item);
Inaktiv(&A000_Item);
Aktiv(&None_Item);
Segment=SEGMENT_NONE;
break;
}
SetMenuStrip(WindowPtr,&Menu1);
break;
case ITEM_VIDEO:
switch(sub)
{
case SUBITEM_COLOR:
if(Color_Item.Flags & CHECKED) ColorVideo=COLOR_VIDEO; else ColorVideo=0;
break;
case SUBITEM_MONO:
if(Mono_Item.Flags & CHECKED) MonoVideo=MONO_VIDEO; else MonoVideo=0;
break;
}
break;
case ITEM_SERIAL:
if(SerialPort_Item.Flags & CHECKED) SerialPort=SERIAL_PORT; else SerialPort=0;
break;
case ITEM_ATPLADEN:
ok=0;
switch(sub)
{
case SUBITEM_SYSTEM:
LadeATP("SYS:PC/System/2500prefs",TRUE);
ok=1;
break;
case SUBITEM_SIDECAR:
LadeATP("SYS:Sidecar/2500prefs",TRUE);
ok=1;
break;
}
if(ok)
{
byte=ColorVideo+MonoVideo+SerialPort+Segment+ATP_UNUSED;
SetJanusPrefs(&byte);
}
break;
case ITEM_ATPSICHERN:
ok=0;
switch(sub)
{
case SUBITEM_SYSTEM:
SichereATP("SYS:PC/System/2500prefs",TRUE);
ok=1;
break;
case SUBITEM_SIDECAR:
SichereATP("SYS:Sidecar/2500prefs",TRUE);
ok=1;
break;
}
if(ok)
{
byte=ColorVideo+MonoVideo+SerialPort+Segment+ATP_UNUSED;
SetJanusPrefs(&byte);
}
break;
case ITEM_ATPSETZEN:
byte=ColorVideo+MonoVideo+SerialPort+Segment+ATP_UNUSED;
SetJanusPrefs(&byte);
break;
}
}